﻿
using Microsoft.Extensions.Logging;
using Quartz;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XXX.api.Controllers;
using XXX.api.Log;
using XXX.Bo;
using XXX.Common;
using XXX.Models;
using XXX.Models.XXXEntities;

namespace XXX.api.Quarzs
{
    public class UserInfoSyncjob : IJob
    {
        private readonly ILogger<UserInfoSyncjob> _logger;
        //private readonly ILoggerHelper _logger;

        //  private readonly ICache _cache;
        public UserInfoSyncjob(ILogger<UserInfoSyncjob> logger)
        {
            //_cache = cache;
            _logger = logger;
        }
        public Task Execute(IJobExecutionContext context)
        {
            return Task.Run(() =>
                        {
                            //.....
                            // Console.WriteLine($"{DateTime.Now.ToString()}：开始执行同步第三方数据");
                            _logger.LogInformation("开始执行定时同步");
                            //  //处理全部同步任务
                            //  U8XieTong u8XieTong = new U8XieTong();
                            //  u8XieTong.Clx = "all";
                            //  u8XieTong.Iid = 0;
                            //  MockU8XieTongRepository mockU8XieTong = new MockU8XieTongRepository();
                            //RetModel ret =  mockU8XieTong.AddU8XieTong(u8XieTong);
                            //  _logger.LogInformation("同步结果："+ ret.message);
                            //....同步操作

                            //  我们都知道如果一个从构造方法中获取IOC容器里面的类型，必须该类型也要主要到IOC容器中；
                            //定时清理缓存
                            CacheHelpCore.CleanupCache();
                        });
        }
    }
}
